package com.sea.product.service.impl;



import com.sea.product.entity.Category;
import com.sea.product.entity.Product;
import com.sea.product.mapper.CategoryMapper;
import com.sea.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;
import java.util.Map;

/**
 * @author 陈鸿飞
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;


    @Override
    public List<Category> findCategory() {
        return categoryMapper.findCategory();
    }

    @Override
    public List<Category> findByParentId(Integer id) {
        return categoryMapper.findByParentId(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int save(Category category) {
        return categoryMapper.insert(category);
    }

    @Override
    public List<Product> export() {
        return categoryMapper.export();
    }

    @Override
    public Integer findIdByName(String categoryName) {
        return categoryMapper.findIdByName(categoryName);
    }

    @Override
    public Category findById(Integer id) {
        return categoryMapper.findById(id);
    }

    @Override
    public Integer usave(Category category) {
        return categoryMapper.update(category);
    }
}
